import time

from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

from utils.page import Page


class PageLaborstory(Page):
    """
    实验室预约审批类:提供在实验室预约审批页面的各个操作
    """
    def __init__(self):
        super(PageLaborstory, self).__init__()
        self.page = Page()
        self.url = "http://120.53.243.26:8009/#/labAppointment"
        self.loc_select = (By.CSS_SELECTOR, "#app > div > div.main-container.hasTagsView > section > div > div.box-bottom > form > div:nth-child(1) > div > div > div > div > div > input")
        self.loc_input = (By.CSS_SELECTOR, "#app > div > div.main-container.hasTagsView > section > div > div.box-bottom > form > div:nth-child(1) > div > div > input")
        self.loc_starttime = (By.CSS_SELECTOR, "#app > div > div.main-container.hasTagsView > section > div > div.box-bottom > form > div:nth-child(2) > div > div > input:nth-child(2)")
        self.loc_query = (By.CSS_SELECTOR, "#app > div > div.main-container.hasTagsView > section > div > div.box-bottom > form > div:nth-child(3) > div > button.el-button.el-button--primary.el-button--medium")
        self.loc_reset = (By.CSS_SELECTOR, "#app > div > div.main-container.hasTagsView > section > div > div.box-bottom > form > div:nth-child(3) > div > button.el-button.el-button--default.el-button--medium > span")

    def do_select(self, option):
        """
        完成实验室预约信息查询的选择
        :return: None
        """
        element = self.find(self.loc_select)
        time.sleep(2)
        select = Select(element)
        select.select_by_visible_text(option)

    def input_content(self, content):
        '''
        在输入框中输入内容
        :return:
        '''
        self.input(content, *(self.loc_input))

    def click_starttime(self):
        '''
        点击开始时间按钮
        :return:
        '''
        self.click(self.loc_starttime)

    """
    TODO: 点击选择查询 时间范围
    """

    def click_query(self):
        """
        点击查询
        """
        self.click(self.loc_query)

    def click_reset(self):
        """
        点击重置
        """
        self.click(self.loc_reset)

    """
    TODO: 点击选择查询预约详情的 预约流水号
    """

